<template>
    <div class="page">
        <div class="headerTitle">
            <router-link to="/login" class="iconfont icon-back_light"></router-link>
            <span>会员全网VIP免费看</span>
        </div>
        <div class="indexHeader">
            <div class="swiper-container">
                <div class="swiper-wrapper">
                    <div class="swiper-slide">
                        <img src="/static/img/titleimg.jpg" alt="">
                    </div>
                    <div class="swiper-slide">
                        <img src="/static/img/titleimg1.jpg" alt="">
                    </div>
                    <div class="swiper-slide">
                        <img src="/static/img/titleimg2.jpg" alt="">
                    </div>
                </div>
                <div class="swiper-pagination"></div>
            </div>
        </div>
        <div class="fromBox">
            <input type="text" placeholder="用户名" v-model="user">
            <input type="password" placeholder="密码" v-model="psw">
            <input type="password" placeholder="确认密码" v-model="psws">
            <!-- <input type="text" placeholder="推荐人(选填)"> -->
            <a @click.stop="gotoReg">注册</a>
            <span @click.stop="gotoLogin">已有账号,去登录</span>
        </div>
    </div>
</template>

<script type="text/ecmascript-6">
    import router from "../router/index";
    import swiper from "../../static/javascript/swiper-3.4.2.min.js";
    export default {
        data() {
            return {
                user: "",
                psw: "",
                psws: ""
            };
        },
    
        mounted() {
            let swiper = new Swiper(".swiper-container", {
                pagination: ".swiper-pagination",
                paginationClickable: true
            });
        },
        methods: {
            gotoLogin: function() {
                router.push({
                    path: "/login"
                });
            },
            gotoReg: function() {
                let that = this;
                if (that.psw === that.psws) {
                    $.ajax({
                        url: "http://vapi.dicbs.cn/user/reguser",
                        type: "post",
                        data: {
                            username: that.user,
                            password: that.psw
                        },
                        success: function(data) {
                            console.log(data);
                            if ((data.code = "200")) {
                                alert(data.memages);
                                router.push({
                                    path: "/login"
                                });
                            } else {
                                alert(data.memages);
                                that.user = "";
                                that.psw = "";
                            }
                        }
                    });
                } else {
                    alert("密码不一致,从新输入！");
                    that.psw = ""
                    that.psws = ""
                }
    
            }
        }
    };
</script>

<style>
    
</style>
